package com.tadpole.music.adapter.base;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;


import com.tadpole.music.R;

import java.util.List;

/**
 * Created by Administrator on 2018/10/31 0031.
 */

public class TabAdapter extends FragmentPagerAdapter {
    private List<String> list;
    private List<Fragment> fragmentList;
    private Context context;

    public TabAdapter(List<Fragment> fragmentList , List<String> list, FragmentManager fm, Context context) {
        super(fm);
        this.fragmentList = fragmentList;
        this.list = list;
        this.context = context;
    }

    public View getTabView(int position){
        View v = LayoutInflater.from(context).inflate(R.layout.item_tablayout_unselect, null);
        TextView tv = (TextView) v.findViewById(R.id.tab_item_textview);
        tv.setText(list.get(position));
        return tv;
    }

    @Override
    public Fragment getItem(int position) {
        return fragmentList.get(position);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return list.get(position);
    }
}
